package com.bestcem.xm.txtanls.enums;

import lombok.Getter;

/**
 * @author liheng
 * @version v1.0
 * @date 2021/6/21 16:35
 */
@Getter
public enum ColumnDataTypeEnum {
    /*
     * int
     */
    INT("int", 0),
    /*
     * string
     */
    STRING("string", 1),
    /*
     * float
     */
    FLOAT("float", 2),
    /*
     * object
     */
    OBJECT("object", 3),
    /*
     * longtext
     */
    LONGTEXT("longtext", 4),
    /*
     * datetime
     */
    DATETIME("datetime", 5),
    /*
     * datetime_y
     */
    DATETIME_Y("datetime_y", 6),
    /*
     * datetime_q
     */
    DATETIME_Q("datetime_q", 7),
    /*
     * datetime_m
     */
    DATETIME_M("datetime_m", 8),
    /*
     * datetime_w
     */
    DATETIME_W("datetime_w", 9),
    /*
     * datetime_wd
     */
    DATETIME_WD("datetime_wd", 10),
    /*
     * datetime_d
     */
    DATETIME_D("datetime_d", 11),
    /*
     * group
     */
    GROUP("group", 12),
    /*
     * calc
     */
    CALC("calc", 13);

    private final String name;
    private final int index;

    ColumnDataTypeEnum(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public static ColumnDataTypeEnum getByIndex(int index) {
        for (ColumnDataTypeEnum value : values()) {
            if (value.getIndex() == index) {
                return value;
            }
        }
        return null;
    }
}
